#!/usr/bin/env bash

set -e
shopt -qs extglob

# VERBOSE truthiness is kinda ... verbose
: "${VERBOSE:=1}"
VERBOSE="${VERBOSE,,}"
VERBOSE="${VERBOSE:0:4}"
VERBOSE="${VERBOSE/@(true|yes|[1-9])/1}"
VERBOSE="${VERBOSE}${#VERBOSE}"
VERBOSE="${VERBOSE/y1/1}"
VERBOSE="${VERBOSE:0:1}"
VERBOSE="${VERBOSE/[a-z]/0}"

set -x

if [ -e ./scripts/"$1" ]; then
    ./scripts/"$@"
else
    exec "$@"
fi

if [ "$DAPPER_UID" -ne "-1" ]; then
  chown -R $DAPPER_UID:$DAPPER_GID .
fi
